/**
 * Copyright (c) 2023, iDearHanYu Co., Ltd.
 *
 * SPDX-License-Identifier: 
 *
 * Change Logs:
 * Date           Author       Notes
 * 2024-09-23     chao         first version
 */

#include <lvgl.h>
#include "volumio_music.h"

/* private variables */
static lv_obj_t *startup_main_cont;
static const lv_font_t *font_huge;

/* private functions */
static void _startup_label_anim_y_cb(void *var, int32_t v);
static void _startup_label_anim_deleted_cb(struct _lv_anim_t *a);

static void _startup_label_anim_y_cb(void *var, int32_t v)
{
    lv_obj_set_y(var, v);
}

static void _startup_label_anim_deleted_cb(struct _lv_anim_t *a)
{
    volumio_music_page_switch(PAGE_ID_PLAYER);
}

lv_obj_t *volumio_music_startup_create(void)
{
    font_huge = &lv_font_montserrat_48;

    startup_main_cont = lv_obj_create(lv_scr_act());
    lv_obj_remove_style_all(startup_main_cont);
    lv_obj_set_size(startup_main_cont, LV_HOR_RES, LV_VER_RES);

    lv_obj_t *startup_label = lv_label_create(startup_main_cont);
    lv_obj_set_style_text_font(startup_label, font_huge, 0);
    lv_obj_set_style_text_color(startup_label, lv_palette_main(LV_PALETTE_BLUE), 0);
    lv_label_set_text(startup_label, "HANYU");//"HIFI Digital Audio Player"
    lv_obj_align(startup_label, LV_ALIGN_TOP_MID, 0, -50);

    lv_anim_t a;
    lv_anim_init(&a);
    lv_anim_set_var(&a, startup_label);
    lv_anim_set_time(&a, 3000);
    lv_anim_set_path_cb(&a, lv_anim_path_bounce);
    lv_anim_set_deleted_cb(&a, _startup_label_anim_deleted_cb);
    lv_anim_set_values(&a, -50, LV_VER_RES / 2 - 50);
    lv_anim_set_exec_cb(&a, _startup_label_anim_y_cb);
    lv_anim_start(&a);

    return startup_main_cont;
}

void volumio_music_startup_destroy(void)
{
    lv_obj_del(startup_main_cont);
}


